package usb;
import java.util.Scanner;

public class Test07 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("输入人数");
        int peoplenum =  sc.nextInt();
        System.out.println("输入倒霉数字");
        int badnum = sc.nextInt();
        boolean[] people = new boolean[peoplenum];
        for (int i = 0; i < people.length; i++) {
            people[i] = true;
        }
        int count = 0;
        while (true) {
            int  index = 0;
            for (int i = 0; i < people.length; i++) {
                if (people[i]) {
                    count++;
                    if(count%badnum==0){
                        people[i] = false;
                    }
                }
            }
            for (int i = 0; i < people.length; i++){
                if (people[i]) {
                    index ++;
                }
            }
            if(index==1){
                break;
            }
        }
        for (int i = 0; i < people.length; i++) {
            if (people[i]) {
                System.out.println("最后剩下的人是："+(i+1));
            }
        }
        System.out.println("最后一个人的数为"+ count);
        System.out.println("游戏结束");
    }
}
